﻿@model IEnumerable<TracNghiem.Models.Test_QuestionModel>
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/themes/template/style/css/jquery.countdown.css")" />
<script type="text/javascript" src="@Url.Content("~/Content/themes/template/style/js/jquery.plugin.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/themes/template/style/js/jquery.countdown.js")"></script>
<style>
    .countdown
    {
        float: left;
        width: 240px;
    }
</style>
<div class="vc-page-center clearfix">
    <div class="2colpage clearfix">
        <div class="vc-sidebar-left">
            <div class="left-box">
                <div class="title-box">
                    <a class="title">Kiểm tra</a>
                </div>
                <div class="content-box">
                    <ul id="left-menu" class="left_menu">
                        @Html.Raw(ViewBag.menu)
                    </ul>
                </div>
            </div>
        </div>
        <div class="vc-content">
            
            @if (Request.Browser.Browser == "InternetExplorer" || Request.Browser.Browser == "IE")
            {
                <div class="ie_check"> Chương trình không sử dụng trên IE. Vui lòng sử dụng Chrome hoặc Firefox!</div>
                return;
            }
            @*   <div class="moving-news">
                <div class="title">
                    <a href="#">Thông Báo:</a>
                </div>
              <div class="promo-news">
                    <marquee width="580" onmouseover="this.stop();" onmouseout="this.start();" scrolldelay="0"
                        scrollamount="4">			           
							                        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                                                    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
                                                    HỆ THỐNG ÔN-THI TRẮC NGHIỆM TRỰC TUYẾN VNPT-ĐIỆN BIÊN
			                                    </marquee>
                </div>
            </div>*@
            
            <script language="javascript">
                function changeServicesMenu() {
                    document.getElementById("giaitri").setAttribute("class", "expanded");
                    var userAgent = navigator.userAgent.toLowerCase();
                    if (userAgent.indexOf("firefox") != -1) {
                        document.getElementById("ulgiaitri").style.display = "block";
                    }
                }
            </script>
            @{
                string cau_hoi_id = "";
                int stt = 0;
                int count = 1;
            }
            <span id="shortly" class="countdown"></span>
            <br>
            <br>
            <br>
            @using (Html.BeginForm("Test_Start", "Test_Service", FormMethod.Post, new { id = "Test_Start", name = "Test_Start" }))
            {
                <input type="hidden" name="test_hidden" value="test" />
                <fieldset>
                    <legend>
                        <h3>
                            <b>Làm bài trắc nghiệm</b></h3>
                    </legend>
                    @Html.Raw("<div id='my_class0' class=\"my_class\">")
                    @foreach (var item in Model)
                    {
                        stt++;
                        if (cau_hoi_id != item.id.ToString())
                        {
                            if (stt != 1)
                            { 
                        @Html.Raw("</div>")
                        @Html.Raw("<div STYLE='font-size: 16px' id='my_class" + count + "' class=\"my_class\">") 
                                count++;
                            }
                        <b><font size='3'>Câu @count: @item.name</font></b>  
                        }
                        
                        <li>
                            <input id='cb@(stt)' type="checkbox" class="cb_class" value="1" name='cb@(stt)' />
                            @*<input type="hidden" id="cb1" name="cb1">*@ <font size='3'>@item.cau_tl_name</font>
                            @*<input type="hidden" name="cau_tl_id" value="@item.cau_tl_id" />
                            <input type="hidden" name="cau_hoi_id" value="@item.id" />*@ @*<input id='cb' type='hidden' value='0' name='cb' />*@
                        </li>                
                        //if (cau_hoi_id != item.id.ToString())
                        //{
                        if (stt == Model.ToArray().Length)
                        {
                        @Html.Raw("</div>")
                        }
                        //}
                        cau_hoi_id = item.id;
                    }
                </fieldset>
                <input type="button" id="shortlyStart" value="Câu tiếp" />
   
            }
            <style>
                .my_class
                {
                    display: none;
                }
                .my_class#my_class0
                {
                    display: block;
                }
            </style>
            <script>
                function unCheckThem(Formname) {
                    var checks = document.getElementsByName('cb');
                    var boxLength = checks.length;
                    for (i = 0; i < boxLength; i++) {
                        checks[i].checked = false;
                    }
                    return;
                }
                function onlyMe(FormName, myBoxId) {
                    unCheckThem(FormName);
                    myBoxId.checked = "true";
                }
            </script>
    <script>
    var checktest= '@ViewBag.checktest';
    $(document).ready(function () {
        if(checktest!="")
        {
            alert("Ban chi duoc thi mot lan");
            var url = '@Url.Action("Home", "Test_Service")';
            window.location.href = url;    
        }
        initTime();       
    });

    var shortly = 0;
    $('#shortly').countdown({ until: shortly, format: 'MS',
        onExpiry: liftOff, onTick: watchCountdown
    });
    var count_class = 0;
    var cb_name="";
    var selectedBox = null;

    $(document).ready(function() {
        $(".cb_class").click(function() {
            selectedBox = this.id;

            $(".cb_class").each(function() {
                if ( this.id == selectedBox )
                {
                    this.checked = true;
                    cb_name =  this.name;
                }
                else
                {
                    this.checked = false;
                };        
            });
        });    
    });
    $('#shortlyStart').click(function () {
        initTime();
        nextquestion();
    });

    function nextquestion() {
        if(count_class==@(count)-1)
        {
            document.getElementById("Test_Start").submit();
        }
        else
        {
            document.getElementById("my_class" + count_class).style.display = "none";
        }
        if(count_class==@(count)-2)
        {
           document.getElementById("shortlyStart").value="Hoàn thành"; 
        }    
        
        ///////////////document.getElementById("cb1" + count_class).style.display = "none";
        if(cb_name!="")
            document.getElementById(cb_name).className = "cb_class1";  

        count_class++;
        document.getElementById("my_class" + count_class).style.display = "block";
    }
    function liftOff() {
        nextquestion();
        initTime();
    }
    var time = @ViewBag.thoi_gian;
    function initTime() {
        try
        {
            shortly = new Date();
            shortly.setSeconds(shortly.getSeconds() + time+0.5);
            $('#shortly').countdown('option', { until: shortly });
        }
        catch(err) {
            alert("Trinh duyet bi loi, hay thu dung phien ban khac");
            var url = '@Url.Action("Home", "Test_Service")';
            window.location.href = url;
        }
    }
    function watchCountdown(periods) {
        $('#monitor').text('Just ' + periods[5] + ' minutes and ' +
		periods[6] + ' seconds to go');
    }
    </script>
